// component/tab/tab.js
Component({
  options: {
    multipleSlots: true //在组件定义时的选项中启用多slot支持
  },
  /**
   * 组件的属性列表
   */
  properties: {
    propArray: {
      type: Array,
    },
    width: {
      type: String,
      value: 0
    },
    placeholderText:{
      type:String,
      value:"请输入要查询的内容"
    },
    searchImg:{
      type:String
    },
    bindBtn:{
      type:String
    }
  },

  /**
   * 组件的初始数据
   */
  data: {
    num: 0,
    realtime: true,
  },


  /**
   * 组件的方法列表
   */
  methods: {
    clickTab: function (e) {
      var that = this;
      if (this.data.num === e.currentTarget.dataset.index) {
        return false;
      } else {
        that.setData({
          num: e.currentTarget.dataset.index,
          realtime: !that.data.realtime
        })
        this.triggerEvent("currentTab", {
          num: e.currentTarget.dataset.index
        })
      }
    },
    bindfocus:function(e){
      console.log(e)
      this.setData({
        placeholderText:""
      })
    },
    b:function(e){
if(e.detail.value == ""){
  this.setData({
    placeholderText:"请输入要查询的内容"
  })
}
    },
    Bipt: function (e) {
      console.log(e);
      if (e.detail.value != "") {
        this.setData({
          iptValue: e.detail.value,
          searchImg: "/images/close.png",
          bindBtn: "dBtn"
        })
      } else if (e.detail.value == "") {
        this.setData({
          iptValue: e.detail.value,
          searchImg: "/images/search.png",
          bindBtn: "sBtn"
        })
      }
    },
    dBtn: function (e) {
      console.log(e)
      this.setData({
        iptValue: "",
        searchImg: "/images/search.png",
        placeholderText:"请输入要查询的内容"
      })
      this.triggerEvent("delete")
    },
    SerchBtn: function (e) {
      console.log(e);
      this.triggerEvent("serch", this.data.iptValue, )
    }
  }
})